//
// Created by Tony on 2024/7/2.
//

#ifndef PARSER_CLASS_DEFINE_H
#define PARSER_CLASS_DEFINE_H

#include "../../AstList.h"
#include "../../leaf/Name.h"
#include "../AccessFlags.h"
#include "ClassBody.h"
#include <cstdint>

namespace Parser {

class ClassDefine final : public AstList {
    string nodeName;
    int32_t mClassId{};

public:
    explicit ClassDefine(const vector<shared_ptr<Ast>>& children) : AstList(children) {
        nodeName = __func__;
    }

    RtCode::AccessFlag getAccessFlags() {
        return static_pointer_cast<AccessFlags>(children[0])->getFlags();
    }

    string getName() { return static_pointer_cast<Name>(children[1])->name(); }

    shared_ptr<ClassBody> getClassBody() { return static_pointer_cast<ClassBody>(children[2]); }

    void setClassId(int32_t classId) { mClassId = classId; }

    int32_t getClassId() const { return mClassId; }

    int32_t accept(Compiler::Visitor* visitor) override;
};

} // namespace Parser

#endif // PARSER_CLASS_DEFINE_H
